package com.care.doctor.server.service.impl;

import com.care.common.core.domain.Result;
import com.care.doctor.common.domain.DTODepartment;
import com.care.doctor.common.req.ListReq;
import com.care.doctor.server.mapper.DepartmentMapper;
import com.care.doctor.server.service.DepartmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 靳家振
 * @Date: 2024/3/22 19:44
 * @Description:
 **/

@Service
public class DepartmentServiceImpl implements DepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;
    @Override
    public Result<PageInfo<DTODepartment>> findDepartment(ListReq req) {
        PageHelper.startPage (req.getPageNum (),req.getPageSize ());
        List<DTODepartment> list = departmentMapper.findDepartment(req);
        PageInfo<DTODepartment> info = new PageInfo<> (list);
        return Result.success (info);
    }

    @Override
    public Result listAll() {
        List<DTODepartment> list = departmentMapper.listAll();
        return Result.success (list);
    }
}
